package BasicMethod;
import java.util.*;

public class sleep_demo {
    // public static void main(String args[]) {
    //     try { 
    //        System.out.println(new Date( ) + "\n"); 
    //        Thread.sleep(1000*3);   // 休眠3秒
    //        System.out.println(new Date( ) + "\n"); 
    //     } catch (Exception e) { 
    //         System.out.println("Got an exception!"); 
    //     }
    //  }

    // public static void main(String args[]) {
    //     try {
    //        long start = System.currentTimeMillis( );
    //        System.out.println(new Date( ) + "\n");
    //        Thread.sleep(5*60*10);
    //        System.out.println(new Date( ) + "\n");
    //        long end = System.currentTimeMillis( );
    //        long diff = end - start;
    //        System.out.println("Difference is : " + diff);
    //     } catch (Exception e) {
    //        System.out.println("Got an exception!");
    //     }
    //  }

    // public static void main(String args[]) {
    //     Calendar c = Calendar.getInstance();//默认是当前日期
    //     System.out.println(c.get(Calendar.HOUR_OF_DAY) + "\n");
    // }

    public static void main(String args[]) {
        String months[] = {
        "Jan", "Feb", "Mar", "Apr",
        "May", "Jun", "Jul", "Aug",
        "Sep", "Oct", "Nov", "Dec"};
        
        int year;
        // 初始化 Gregorian 日历
        // 使用当前时间和日期
        // 默认为本地时间和时区
        GregorianCalendar gcalendar = new GregorianCalendar();
        // 显示当前时间和日期的信息
        System.out.print("Date: ");
        System.out.print(months[gcalendar.get(Calendar.MONTH)]);
        System.out.print(" " + gcalendar.get(Calendar.DATE) + " ");
        System.out.println(year = gcalendar.get(Calendar.YEAR));
        System.out.print("Time: ");
        System.out.print(gcalendar.get(Calendar.HOUR) + ":");
        System.out.print(gcalendar.get(Calendar.MINUTE) + ":");
        System.out.println(gcalendar.get(Calendar.SECOND));
        
        // 测试当前年份是否为闰年
        if(gcalendar.isLeapYear(year)) {
           System.out.println("当前年份是闰年");
        }
        else {
           System.out.println("当前年份不是闰年");
        }
     }
}
